/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package chapter5;

/**
 *
 * @author Denise Carolina
 */
public class LoopsAndIterators {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        //while (int i = 0){}

        do{
            System.out.println("inside the loop");
        }while(false);

        for (int i = 0; i < 5; i++) {
            System.out.print(i + " ");
        }
        System.out.println("");
       // System.out.println("i::" + i); illegal i is out of scope

        //for(;;){System.out.println("endless loop");} // endless loop
        int i = 0;
        for (;i <5;){

            i++;
           System.out.println("inside loop i:: " + i);
           //i++;
        }

        int x = 3;
        for (x=12; x < 20; x++){}
        System.out.println("x:: " + x);

        int b = 3;
        for (int a=1, j = 1; b != 1; System.out.println("iterate " + j++), j--){
            b = b-a;
        }

        for (int k=0,j=0; k<10 && j<10; k++,j++){
            System.out.println("k:: " + k + " j:: " + j);
        }

        // Basic
        int []array = {1,2,3,4};
        for (int j = 0; j < array.length; j++) {
            System.out.println("a[j]:: " + array[j]);
        }

        // enhanced

        for(int y: array){
            System.out.println("y:: "+ y);
        }

        int [][] twoDee = {{1,2,3},{4,5,6},{7,8,9}};
        for(int[] xy: twoDee){
            System.out.println("xy:: " + xy);
        }

        long []La = {4l,5l,6l};
//        for(int lValue: La){
//            System.out.println("doesn't fit in int");
//        }

        for(int r = 1; r <= 5; r++ ){
            System.out.println("before - " + r);
            if(r == 1 | r == 3 | r == 5){
                continue;
            }
            System.out.println("after - " + r);
        }

        System.out.println("entering label");
        label:
            for(int g = 1; g <=5 ; g++){
                System.out.println("inside label " + g);
//                if(g == 1) break label;
                if(g == 2) continue label;

            }
        System.out.println("after label");

        for(int x1 = 1; x1<5;x1++){
           // x1 = 0;
            System.out.println("x1:: " + x1);
        }
    }

}
